CC=gcc
CFLAG= -c -g 
TARGET=app

objects=app.o
app:$(objects)
	$(CC) -o $(TARGET) $^
	@rm -rf *.o *~ core .depend .*.cmd *.mod.c .tmp_versions *.order *.symvers
$(objects):%o:%c
	$(CC) $(CFLAG) $< -o $@ 

# Comment/uncomment the following line to disable/enable debugging
DEBUG = y


# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
  DEBFLAGS = -O -g -DSCULL_DEBUG # "-O" is needed to expand inlines
else
  DEBFLAGS = -O2
endif

ccflags-y += $(DEBFLAGS)
ccflags-y += -I$(LDDINC)

ifneq ($(KERNELRELEASE),)
# call from kernel build system

#scull-objs := mem_dev.o 

obj-m	:= mem_dev.o

else

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD       := $(shell pwd)

drv:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINC=$(PWD)/../include modules
	@rm -rf *.o *~ core .depend .*.cmd *.mod.c .tmp_versions *.order *.symvers
endif

clean:
	rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions *.order *.symvers

depend .depend dep:
	$(CC) $(ccflags-y) -M *.c > .depend


ifeq (.depend,$(wildcard .depend))
include .depend
endif
